import * as THREE from 'three'
import eventBus from '@/utils/eventBus';

// 创建透视相机
const camera = new THREE.PerspectiveCamera(75, window.innerHeight / window.innerWidth, 1, 100000);
// 设置相机位置
camera.position.set(100, 100, 100);

class CameraModule {
    constructor() {
        this.activeCamera = camera;
        this.collections = {
            'default': camera
        };

        eventBus.on('toggleCamera', name => {
            this.setActive(name)
        })
    }

    add(name, camera) {
        this.collections[name] = camera
    }

    setActive(name) {
        this.activeCamera = this.collections[name]
    }
}

export default new CameraModule();